import { createElement, HTMLAttributes, type FC } from 'react';
import classNames from 'classnames';
import { nagTitleDefaultProps } from './defaultProps';
import type { NagTitleOptions } from './type';

export interface NagTitleProps extends NagTitleOptions, HTMLAttributes<HTMLDivElement> {}

const NagTitle: FC<NagTitleProps> = (props) => {
  const { className, ui, children, forwardedRef, ...nagTitleProps } = props;

  return createElement(
    'div',
    { ref: forwardedRef, className: classNames({ ui }, 'title', className), ...nagTitleProps },
    children,
  );
};

NagTitle.displayName = 'NagTitle';
NagTitle.defaultProps = nagTitleDefaultProps;

export default NagTitle;
